var coreExamPaper = Gikam.getPageObject({

    baseUrl : IFM_CONTEXT + '/secure/baseline/rm/train/exam-papers',

    getStartFormFields : function(){
        return[{
            field : 'examName',
            title : 'T_CORE_EXAM.EXAMNAME',
            type : 'choose',
            cleanable : false,
            preInsert : true,
            single : true,
            editable : false,
            category : 'exam',
            validators : ['notEmpty'],
            onAfterChoose : function (rows,index) {
                if (rows){
                    this.setData({
                        examName : rows[0].examName,
                        examId : rows[0].id
                    })
                }
            }
        },{
            field : 'examBeginTime',
            title : 'T_CORE_EXAM.EXAMBEGINTIME',
            type : 'dateTime',
            validators : [ 'notEmpty' ],
            onChange : function (field,value,index) {
                if (Gikam.isNotEmpty(this.options.data.examEndTime) && value){
                    let endDate = new Date(this.options.data.examEndTime);
                    let startDate = new Date(value);
                    if(startDate > endDate){
                        this.setData({
                            examBeginTime :'',
                            examDuration : '',
                            id : this.options.data.id
                        });
                        Gikam.alert('STARTDATE.NO.MORE.THAN.ENDDATE');
                    }else{
                        let ss = endDate.getTime() - startDate.getTime();
                        let min = Math.floor(ss/60000);
                        this.setData({
                            examBeginTime : value,
                            examDuration : min,
                            id : this.options.data.id
                        });
                        this.setData({
                            examBeginTime : value,
                            id : this.options.data.id
                        });
                    }
                }
            },
            preInsert : true
        }, {
            field : 'examEndTime',
            title : 'T_CORE_EXAM.EXAMENDTIME',
            type : 'dateTime',
            validators : [ 'notEmpty' ],
            onChange : function (field,value,index) {
                if (Gikam.isNotEmpty(this.options.data.examBeginTime) && value){
                    let startDate = new Date(this.options.data.examBeginTime);
                    let endDate = new Date(value);
                    if(startDate > endDate){
                        this.setData({
                            examEndTime :'',
                            examDuration : '',
                            id : this.options.data.id
                        });
                        Gikam.alert('STARTDATE.NO.MORE.THAN.ENDDATE');
                    }else{
                        let ss = endDate.getTime() - startDate.getTime();
                        let min = Math.floor(ss/60000);
                        this.setData({
                            examEndTime : value,
                            examDuration : min,
                            id : this.options.data.id
                        });
                    }
                }
            },
            preInsert : true
        },{
            field : 'examUserName',
            title : 'T_CORE_EXAM_PAPER_EXT.USERNAME',
            type: 'choose',
            category: 'user',
            preInsert : true,
            validators : ['notEmpty'],
            cleanable : false,
            onAfterChoose: function (rows, index) {
                if (rows) {
                    this.setData({
                        examUserId : rows.map(row => row.id).join(","),
                        examUserName : rows.map(row => row.userName).join(",")
                    })
                }
            },
            onBeforeChoose: function () {
                return {
                    status_EQ:'activated'
                }
            }
        }, {
            field: 'remark',
            title : 'T_CORE_EXAM_PAGER.REMARK',
            type : 'textarea',
            preInsert : true
        },]
    },

    getStartListColumns : function(){
        return[{
            checkbox : true
        },{index: true},{
            field : 'examPaperCode',
            title : 'T_CORE_EXAM_PAPER.EXAMPAPERCODE',
            width : 140
        }, {
            field : 'ext$.examname',
            title : 'T_CORE_EXAM.EXAMNAME',
            width : 140
        }, {
            field : 'ext$.totalscore',
            title : 'T_CORE_EXAM_TMPL.TOTALSCORE',
            width : 100
        }, {
            field : 'examBeginTime',
            title : 'T_CORE_EXAM.EXAMBEGINTIME',
            width : 150
        }, {
            field : 'examEndTime',
            title : 'T_CORE_EXAM.EXAMENDTIME',
            width : 150
        },{
            field : 'examUserName',
            title : 'T_CORE_EXAM_PAPER_EXT.USERNAME',
        },{
            field : 'remark',
            title : 'T_CORE_EXAM_PAGER.REMARK',
            width : 150
        }]
    },

    getStartDoneListColumns : function(){
        return[{
            checkbox : true
        },{index: true},{
            field : 'ext$.exampapercode',
            title : 'T_CORE_EXAM_PAPER.EXAMPAPERCODE',
            width : 140
        }, {
            field : 'examName',
            title : 'T_CORE_EXAM.EXAMNAME',
            width : 140
        }, {
            field : 'ext$.totalscore',
            title : 'T_CORE_EXAM_TMPL.TOTALSCORE',
            width : 100
        }, {
            field : 'examBeginTime',
            title : 'T_CORE_EXAM.EXAMBEGINTIME',
            width : 150
        }, {
            field : 'examEndTime',
            title : 'T_CORE_EXAM.EXAMENDTIME',
            width : 150
        },{
            field : 'ext$.examusernames',
            title : 'T_CORE_EXAM_PAPER_EXT.USERNAME',
        },{
            field : 'ext$.remark',
            title : 'T_CORE_EXAM_PAGER.REMARK',
            width : 150
        }]
    },

    getEditListColumns : function() {
        return [ {
            radio : true
        },{index: true},{
            field : 'examPaperCode',
            title : 'T_CORE_EXAM_PAPER.EXAMPAPERCODE',
            width : 140
        }, {
            field : 'ext$.examname',
            title : 'T_CORE_EXAM.EXAMNAME'
        }, {
            field : 'ext$.totalscore',
            title : 'T_CORE_EXAM_TMPL.TOTALSCORE',
            width : 140
        }, {
            field : 'examBeginTime',
            title : 'T_CORE_EXAM.EXAMBEGINTIME',
            width : 180
        }, {
            field : 'examEndTime',
            title : 'T_CORE_EXAM.EXAMENDTIME',
            width : 180
        }, {
            field : 'actBeginTime',
            title : 'T_CORE_EXAM_PAPER.ACTBEGINTIME',
            width : 180
        }, {
            field : 'actEndTime',
            title : 'T_CORE_EXAM_PAPER.ACTENDTIME',
            width : 180
        }, {
            field : 'score',
            title : 'T_CORE_EXAM_PAPER.SCORE',
            width : 140
        } ];
    },

    getBaseInfoFormFields : function() {
        return [ {
            field : 'ext$.examname',
            title : 'T_CORE_EXAM.EXAMNAME',
            readonly : true
        }, {
            field : 'userName',
            title : 'T_CORE_EXAM_PAPER.USERNAME',
            readonly : true
        }, {
            field : 'ext$.totalscore',
            title : 'T_CORE_EXAM_TMPL.TOTALSCORE',
            readonly : true
        }, {
            field : 'actBeginTime',
            title : 'T_CORE_EXAM_PAPER.ACTBEGINTIME',
            type : 'dateTime',
            readonly : true
        }, {
            field : 'actEndTime',
            title : 'T_CORE_EXAM_PAPER.ACTENDTIME',
            type : 'dateTime',
            readonly : true
        }, {
            field : 'score',
            title : 'T_CORE_EXAM_PAPER.SCORE',
            readonly : true
        } ];
    },

    getAnswerFields : function() {
        return [ {
            field : 'ext$.questiontype',
            title : 'T_CORE_QUESTION.QUESTIONTYPE',
            type : 'select',
            category : 'sys',
            param : {
                codeCategoryId : 'coreQuestionType'
            },
            readonly : true
        }, {
            field : 'ext$.questioncontent',
            title : 'T_CORE_QUESTION.QUESTIONCONTENT',
            colspan : 3,
            readonly : true
        }, {
            field : 'answer',
            title : 'T_CORE_EXAM_PAPER_ANSWER.ANSWER',
            colspan : 3,
            type : 'textarea',
            height : 50
        }, {
            field : 'judgementAnswer',
            title : 'T_CORE_QUESTION.ANSWER',
            type : 'select',
            category : 'sys',
            param : {
                codeCategoryId : 'coreJudgementOption'
            },
            onChange : function(field, value) {
                Gikam.getComp('core-exam-paper-detail-exam-paper-answer-form').setData({
                    answer : value,
                    judgementAnswer : value
                });
            }
        } ];
    },

    getQuestionOptColumns : function() {
        return [ {
            field : 'optCode',
            title : 'T_CORE_QUESTION_OPT.OPTCODE',
            contentAlign : 'center'
        }, {
            field : 'optContent',
            title : 'T_CORE_QUESTION_OPT.OPTCONTENT'
        } ];
    },

    getAnswerCardColumns : function() {
        return [ {
            field : 'columnValue1',
            title : '',
            contentAlign : 'center',
            width : 220,
            tagFormatter : function(row) {
                if (Gikam.isNotEmpty(row.columnValue1)) {
                    var type = 'info';
                    if (row.answered1 === '1') {
                        type = 'danger';
                    }
                    return {
                        type : type,
                        value : row.columnValue1
                    }
                }
            }
        }, {
            field : 'columnValue2',
            title : '',
            contentAlign : 'center',
            width : 220,
            tagFormatter : function(row) {
                if (Gikam.isNotEmpty(row.columnValue2)) {
                    var type = 'info';
                    if (row.answered2 === '1') {
                        type = 'danger';
                    }
                    return {
                        type : type,
                        value : row.columnValue2
                    }
                }
            }
        }, {
            field : 'columnValue3',
            title : '',
            contentAlign : 'center',
            width : 220,
            tagFormatter : function(row) {
                if (Gikam.isNotEmpty(row.columnValue3)) {
                    var type = 'info';
                    if (row.answered3 === '1') {
                        type = 'danger';
                    }
                    return {
                        type : type,
                        value : row.columnValue3
                    }
                }
            }
        }, {
            field : 'columnValue4',
            title : '',
            contentAlign : 'center',
            width : 220,
            tagFormatter : function(row) {
                if (Gikam.isNotEmpty(row.columnValue4)) {
                    var type = 'info';
                    if (row.answered4 === '1') {
                        type = 'danger';
                    }
                    return {
                        type : type,
                        value : row.columnValue4
                    }
                }
            }
        } ];
    },

    getExamReviewListColumns : function() {
        return [ {
            index : true,
        }, {
            field : 'ext$.exampapercode',
            title : 'T_CORE_EXAM_PAPER.EXAMPAPERCODE',
            width : 140
        }, {
            field : 'examName',
            title : 'T_CORE_EXAM.EXAMNAME',
            // type : 'link',
            width : 140
        }, /*{
            field : 'questionMethod',
            title : 'T_CORE_EXAM.QUESTIONMETHOD',
            type : 'select',
            category : 'sys',
            param : {
                codeCategoryId : 'coreQuestionMethod'
            },
            width : 140
        },*/ {
            field : 'ext$.tmplname',
            title : 'T_CORE_EXAM_TMPL.TMPLNAME',
            width : 140
        }, {
            field : 'ext$.totalscore',
            title : 'T_CORE_EXAM_TMPL.TOTALSCORE',
            width : 140
        }, {
            field : 'examBeginTime',
            title : 'T_CORE_EXAM.EXAMBEGINTIME',
            width : 150
        }, {
            field : 'examEndTime',
            title : 'T_CORE_EXAM.EXAMENDTIME',
            width : 150
        }, {
            field : 'ext$.examusernames',
            title : 'T_CORE_EXAM_PAPER_EXT.USERNAME',
        },/*{
            field : 'examDuration',
            title : 'T_CORE_EXAM.EXAMDURATION',
            width : 140
        },*/ /*{
            field : 'examCategory',
            title : 'T_CORE_EXAM.EXAMCATEGORY',
            type : 'select',
            category : 'sys',
            param : {
                codeCategoryId : 'coreQuestionCategory'
            },
            width : 150
        },*/ {
            field : 'lastUpdatedByName',
            title : 'T_CORE_EXAM.LASTUPDATEDBYNAME',
            width : 140
        }, {
            field : 'lastUpdatedTime',
            title : 'T_CORE_EXAM.LASTUPDATEDTIME',
            width : 150
        } ];
    },

    getExamPaperReviewListColumns : function() {
        return [ {
            checkbox : true
        }, {
            index : true
        }, {
            field : 'activatedFlag',
            title : 'T_CORE_EXAM_PAPER.ACTIVATEDFLAG',
            formatter : function(i, v, row) {
                if (row.activatedFlag === '1') {
                    return Gikam.propI18N('CORE.MODULE.TRAIN.EXAM_PAPER.TITLE.STATUS.REVIEW_COMPLETED');
                } else if (row.activatedFlag === '0') {
                    return Gikam.propI18N('CORE.MODULE.TRAIN.EXAM_PAPER.TITLE.STATUS.REVIEW_UNCOMPLETE');
                }
            }
        }, {
            field : 'userName',
            title : 'T_CORE_EXAM_PAPER.USERNAME',
            type : 'link'
        }, {
            field : 'actBeginTime',
            title : 'T_CORE_EXAM_PAPER.ACTBEGINTIME'
        }, {
            field : 'actEndTime',
            title : 'T_CORE_EXAM_PAPER.ACTENDTIME'
        }, {
            field : 'score',
            title : 'T_CORE_EXAM_PAPER.SCORE'
        } ];
    },

    getExamPaperSingleChoiceAnswerListColumns : function() {
        return [ {
            field : 'ext$.questioncontent',
            title : 'T_CORE_QUESTION.QUESTIONCONTENT'
        }, {
            field : 'ext$.correctanswer',
            title : 'CORE.MODULE.TRAIN.EXAM_PAPER_ANSWER.TITLE.CORRECTANSWER'
        }, {
            field : 'ext$.singlechoicescore',
            title : 'CORE.MODULE.TRAIN.EXAM_PAPER_ANSWER.TITLE.TMPLSCORE'
        }, {
            field : 'answer',
            title : 'T_CORE_EXAM_PAPER_ANSWER.ANSWER'
        }, {
            field : 'score',
            title : 'T_CORE_EXAM_PAPER_ANSWER.SCORE'
        } ];
    },

    getExamPaperMultipleChoiceAnswerListColumns : function() {
        return [ {
            field : 'ext$.questioncontent',
            title : 'T_CORE_QUESTION.QUESTIONCONTENT'
        }, {
            field : 'ext$.correctanswer',
            title : 'CORE.MODULE.TRAIN.EXAM_PAPER_ANSWER.TITLE.CORRECTANSWER'
        }, {
            field : 'ext$.multiplechoicescore',
            title : 'CORE.MODULE.TRAIN.EXAM_PAPER_ANSWER.TITLE.TMPLSCORE'
        }, {
            field : 'answer',
            title : 'T_CORE_EXAM_PAPER_ANSWER.ANSWER'
        }, {
            field : 'score',
            title : 'T_CORE_EXAM_PAPER_ANSWER.SCORE'
        } ];
    },

    getExamPaperCompletionAnswerListColumns : function() {
        return [ {
            field : 'ext$.questioncontent',
            title : 'T_CORE_QUESTION.QUESTIONCONTENT'
        }, {
            field : 'ext$.correctanswer',
            title : 'CORE.MODULE.TRAIN.EXAM_PAPER_ANSWER.TITLE.CORRECTANSWER'
        }, {
            field : 'ext$.completionscore',
            title : 'CORE.MODULE.TRAIN.EXAM_PAPER_ANSWER.TITLE.TMPLSCORE'
        }, {
            field : 'answer',
            title : 'T_CORE_EXAM_PAPER_ANSWER.ANSWER'
        }, {
            field : 'score',
            title : 'T_CORE_EXAM_PAPER_ANSWER.SCORE'
        } ];
    },

    getExamPaperJudgementAnswerListColumns : function() {
        return [ {
            field : 'ext$.questioncontent',
            title : 'T_CORE_QUESTION.QUESTIONCONTENT'
        }, {
            field : 'ext$.correctanswer',
            title : 'CORE.MODULE.TRAIN.EXAM_PAPER_ANSWER.TITLE.CORRECTANSWER',
            type : 'select',
            category : 'sys',
            param : {
                codeCategoryId : 'coreJudgementOption'
            }
        }, {
            field : 'ext$.judgementscore',
            title : 'CORE.MODULE.TRAIN.EXAM_PAPER_ANSWER.TITLE.TMPLSCORE'
        }, {
            field : 'answer',
            title : 'T_CORE_EXAM_PAPER_ANSWER.ANSWER',
            type : 'select',
            category : 'sys',
            param : {
                codeCategoryId : 'coreJudgementOption'
            }
        }, {
            field : 'score',
            title : 'T_CORE_EXAM_PAPER_ANSWER.SCORE'
        } ];
    },

    getExamPaperShortAnswerListColumns : function() {
        return [ {
            field : 'ext$.questioncontent',
            title : 'T_CORE_QUESTION.QUESTIONCONTENT'
        }, {
            field : 'ext$.correctanswer',
            title : 'CORE.MODULE.TRAIN.EXAM_PAPER_ANSWER.TITLE.CORRECTANSWER'
        }, {
            field : 'ext$.shortanswerscore',
            title : 'CORE.MODULE.TRAIN.EXAM_PAPER_ANSWER.TITLE.TMPLSCORE'
        }, {
            field : 'answer',
            title : 'T_CORE_EXAM_PAPER_ANSWER.ANSWER'
        }, {
            field : 'score',
            title : 'T_CORE_EXAM_PAPER_ANSWER.SCORE',
            editor : true,
            validator : [ 'integer' ]
        } ];
    },

    getQuestionOptColumns : function() {
        return [ {
            field : 'optCode',
            title : 'T_CORE_QUESTION_OPT.OPTCODE'
        }, {
            field : 'optContent',
            title : 'T_CORE_QUESTION_OPT.OPTCONTENT'
        } ];
    }
});